package com.redtrusssoftware.truckloaderpro;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.ParseAnalytics;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseUser;
import com.parse.SignUpCallback;

import com.redtrusssoftware.truckloaderpro.R;

public class SignUp_Activity extends Activity {

	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sign_up);
    }
	
	public void finishSignUp(View view){
		EditText newUserName = (EditText)findViewById(R.id.newusername);
		EditText newPassword = (EditText)findViewById(R.id.newpassword);
		EditText email = (EditText)findViewById(R.id.email);
		ParseUser user = new ParseUser();
		user.setUsername(newUserName.getText().toString());
		user.setPassword(newPassword.getText().toString());
		user.setEmail(email.getText().toString());
		
		user.signUpInBackground(new SignUpCallback() {
			  public void done(ParseException e) {
			    if (e == null) {
			      Toast.makeText(getApplicationContext(), "Sign up successful", Toast.LENGTH_SHORT).show();
			    } else {
			      // Sign up didn't succeed. Look at the ParseException
			      // to figure out what went wrong
			    	String response = e.getMessage();
			    	Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
			    }
			  }
			});
		
			Intent intent = new Intent(getApplicationContext(),NewEventController.class);
			startActivity(intent);
		
			
		}
		
	
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
